package com.shihb.chapter05matchcase

/**
 * Description:匹配数组
 *
 * @author shihb
 * @date 2020/9/30 14:38
 */
object Demo02MatchArray {
  def main(args: Array[String]): Unit = {
    val array: Array[Array[Int]] = Array(Array(0), Array(1, 2), Array(0, 1, 2), Array(1, 2, 3))
    for(arr<-array){
      val res=arr match{
        case Array(0)=>"0"
        case Array(x,y)=>(y,x)
        case Array(0,_*)=>"以0开头的" //_ 忽略一个，_*忽略所有
        case _ => "Nothing"
      }
      println(res)
    }
  }

}
